#include <iostream>
#include <vector>
#include <string.h>
#include <stdlib.h>

using namespace std;

class Solution1
{
public:
    int findRepeatNumber(vector<int> &nums)
    {
        for (int i = 0; i < nums.size(); i++)
        {
            if (i == nums[i])
                continue;
            if (nums[i] == nums[nums[i]] && i != nums[i])
            {
                return nums[i];
            }
            else
            {
                int tmp_0 = nums[i];
                int tmp_1 = nums[nums[i]];
                nums[nums[i]] = tmp_0;
                nums[i] = tmp_1;
            }
        }
        return 0;
    }
};

class Solution
{
public:
    int findRepeatNumber(vector<int> &nums)
    {
        int size = nums.size();
        int *p;
        p = (int *)malloc((size + 1) * sizeof(int));
        memset(p, 0, sizeof(int) * (size + 1));
        for (int j = 0; j < size; j++)
        {
            if (p[nums[j]] == 1)
                return nums[j];
            else
                p[nums[j]]++;
        }
        return 0;
    }
};

int main()
{
    vector<int> tmp;
    int i[7] = {2, 3, 1, 0, 2, 5, 3};
    for (int j = 0; j < 7; j++)
    {
        tmp.push_back(i[j]);
    }
    int k = Solution1().findRepeatNumber(tmp);
    cout << k;
    return 0;
}
